class Vue {
    constructor(options) {
        this.$options = options
        // TODO: data可能是函数
        this._data = options.data
        this.initData()
    }
    initData() {
        let data = this._data
        let keys = Object.keys(data)
        for(let i=0;i<keys.length;i++){
            Object.defineProperty(this, keys[i], {
                enumerable: true,
                configurable: true,
                get: function proxyGetter() {
                    return data[keys[i]]
                },
                set: function proxySetter(value) {
                    data[keys[i]] = value
                }
            })
        }

        for(let i=0;i<keys.length;i++){
            let value = data[keys[i]]
            Object.defineProperty(data, keys[i], {
                enumerable: true,
                configurable: true,
                get: function reactiveGetter() {
                    console.log('获取了这个值');
                    return value
                },
                set: function reactiveSetter(val) {
                    if(val === value) return
                    console.log('设置了这个值');
                    value = val
                }
            })
        }
    }
}

function observer(data) {

}